<?
$title = "User List";
$pageid = "4";
$accessid = ",a10,";

if (isset($_POST['btnsubmit'])) {
    require("required/dbconnect.php");

    $category_eng = $_POST['category_eng'];
    $order_id = $_POST['order_id'];
    $is_publish = $_POST['is_publish'];
    $insert = mysql_query("insert into os_category(name_eng,order_id,is_publish)value('$category_eng','$order_id','$is_publish')") or die(mysql_error());
    header("Location:cat_management.php?action=1");
}



require("required/dbconnect.php");
require("required/function.php");
require("required/header.php");

checkAccess("allow_product_category", 1);
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?
if (!empty($_GET['action'])) {
    switch ($_GET['action']) {
        case 1:
            $msg = "<div class='dw_success'>Data inserted</div>";
            break;
        case 2:
            $msg = "<div class='dw_success'>Data Deleted</div>";
            break;
        case 3:
            $msg = "<div class='dw_success'>Data Updated</div>";
            break;
        default:
            $msg = "";
            break;
    }
    echo "<script>displayMsg('divMsg')</script>";
} else {
    $msg = "";
}


$get_category = mysql_query("select * from os_category order by order_id asc");
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
    <tr>

        <td valign="top">
            <div class="title">Product Main Category</div>
            <div id="divMsg"><?= $msg ?></div>
            <br />
            <table width="100%" class="solidborder">
                <tr class="table_header">
                    <td width="4%">No</td><td width="63%">Name</td><td width="10%">Order Id</td>
                    <td width="10%">Display</td>
                    <td width="23%">Action</td>
                </tr>
                <? if (mysql_num_rows($get_category) == 0) { ?>
                    <tr valign="top">
                        <td align="center" colspan="7">
                            - No record found - 
                        </td>

                        <?
                    } else {
                        $no = 1;
                        while ($a = mysql_fetch_array($get_category, MYSQL_ASSOC)) {
                            $enid = en_id($a['id']);
                            if ($no % 2 == 0) {
                                $class1 = "table_item_even";
                                $class2 = "table_item_odd";
                            } else {
                                $class1 = "table_item_odd";
                                $class2 = "table_item_even";
                            }
                            ?>
                        <tr height="20" valign="top" class="<?= $class1 ?>"  onmouseover="this.className='table_item_mouseover'" 
                            onmouseout="this.className='<?= $class1 ?>'">
                            <td align="center"><?= $no ?></td><td><?= $a['name_eng'] ?></td>
                            <td align="center"><?= $a['order_id'] ?></td>
                            <td align="center"><?= convertYesNo($a['is_publish']) ?></td>
                            <td align="center"><a href="cat_edit.php?id=<?= $enid ?>"><img src="images/icons/edit.gif" border="0" /></a>  <a href="cat_delete.php?id=<?= $enid ?>"><img src="images/icons/delete.gif" border="0" /></a></td>								
                        </tr>
                        <?
                        $no++;
                    }
                }
                ?>

            </table>

            <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post">
                <table>
                    <tr>
                        <td colspan="3"><strong>Add New Category</strong></td>
                    </tr>
                    <tr>
                        <td>Category name(english)</td><td>:</td><td><input class="text" type="text" name="category_eng" size="30"></td>
                    </tr>
                    <tr>
                        <td>Order ID</td><td>:</td><td><input class="text" type="text" name="order_id" size="5"></td>
                    </tr>
                    <tr>
                        <td>Display</td><td>:</td><td>
                            <select name="is_publish">
                                <option value="1">Yes</option>
                                <option value="0">No</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="3"><input type="submit" value="Submit" class="button" name="btnsubmit"></td>
                    </tr>
                </table>
            </form>

        </td>
    </tr>


</table>
<? require("required/footer.php"); ?>

